﻿using Compass.Wasm.Shared;
using Compass.Wasm.Shared.Wms;
using System.Collections.Generic;

namespace Compass.Wpf.ApiServices.Wms;
public interface ILocationService:IBaseService<LocationDto>
{
    Task<ApiResponse<LocationDto>> GetSingleByNameAsync(string name);
    Task<ApiResponse<List<LocationDto>>> GetAllByAreaAsync(Warehouse_e warehouse,Area_e area, string ranks);
}
public class LocationService:BaseService<LocationDto>,ILocationService
{
    private readonly HttpRestClient _client;
    private const string ServiceName = "Location";
    public LocationService(HttpRestClient client) : base(client, ServiceName)
    {
        _client = client;
    }

    public async Task<ApiResponse<LocationDto>> GetSingleByNameAsync(string name)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Name?name={name}"
        };
        return await _client.ExecuteAsync<LocationDto>(request);
    }

    public async Task<ApiResponse<List<LocationDto>>> GetAllByAreaAsync(Warehouse_e warehouse, Area_e area, string ranks)
    {
        var request = new BaseRequest
        {
            Method = RestSharp.Method.Get,
            Route = $"api/{ServiceName}/Area?warehouse={warehouse}&area={area}&ranks={ranks}"
        };
        return await _client.ExecuteAsync<List<LocationDto>>(request);
    }
}